package com.sky.service.impl;

import com.sky.entity.TWallet;
import com.sky.dao.TWalletDao;
import com.sky.service.TWalletService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

/**
 * (TWallet)表服务实现类
 *
 * @author sky
 * @since 2022-11-15 11:42:57
 */
@Service
@Transactional
public class TWalletServiceImpl implements TWalletService {

    @Resource
    private TWalletDao tWalletDao;

    /**
     * 通过用户主键查询钱包余额
     *
     * @param userId 主键
     * @return 实例对象
     */
    @Override
    public BigDecimal queryWalletMoneyById(Integer userId) {
        return tWalletDao.queryWalletMoneyById(userId);
    }

    @Override
    public boolean consume(long userId, BigDecimal money) {
        return tWalletDao.consume(userId, money);
    }

    @Override
    public void refundToWallet(long userId, BigDecimal money) {
        tWalletDao.refundToWallet(userId, money);
    }

    @Override
    public TWallet queryById(long userId) {
        return tWalletDao.queryById(userId);
    }


    /**
     * 新增数据
     *
     * @param tWallet 实例对象
     * @return 实例对象
     */
    @Override
    public void insert(TWallet tWallet) {
        tWalletDao.insert(tWallet);
    }


}
